//
//  UIColor+Category.m
//  XLDoctor
//
//  Created by longma on 2018/9/4.
//  Copyright © 2018年 XLH. All rights reserved.
//

#import "UIColor+Theme.h"

@implementation UIColor (Theme)
+ (UIColor *)mj_appColor {
    return ColorApp;
}
+ (UIColor *)mj_mainColor {
    return ColorMain;
}
+ (UIColor *)mj_lightAppColor {
    return ColorLightApp;
}
+ (UIColor *)mj_redColor {
    return ColorRed;
}
+ (UIColor *)mj_whiteColor {
    return ColorWhite;
}
+ (UIColor *)mj_blackColor {
    return ColorBlack;
}
+ (UIColor *)mj_lightBlackColor {
    return ColorLightBlack;
}
+ (UIColor *)mj_orangeColor {
    return ColorOrange;
}
+ (UIColor *)mj_orangeColor1 {
    return ColorOrange1;
}
+ (UIColor *)mj_grayColor {
    return ColorGray;
}
+ (UIColor *)mj_lightGrayColor {
    return ColorLightGray;
}
+ (UIColor *)mj_backgroundColor {
    return ColorBackground;
}
+ (UIColor *)mj_darkBackgroundColor {
    return ColorBackground;
}
+ (UIColor *)mj_backgroundColor1 {
    return ColorBackground1;
}
+ (UIColor *)mj_lineColor {
    return ColorLine;
}
+ (UIColor *)mj_windowColor {
    return ColorWindow;
}
+ (UIColor *)mj_blueColor {
    return ColorBlue;
}
+ (UIColor *)mj_appAlphaColor {
    return [UIColor.mj_appColor colorWithAlphaComponent:0.15];
}
+ (UIColor *)mj_colorName:(NSString *)name{
    
     if ([name containsString:@"|"]){
        NSArray *lab = [name componentsSeparatedByString:@"|"];
        NSString *light = lab[0];
        NSString *dark = lab[1];
        return [UIColor dm_colorWithColorLight:[self mj_colorName:light] dark:[self mj_colorName:dark]];

    }else if([name containsString:@"rgb"]){
        NSString *newName = [name mj_stringByPreviousString:@"(" LaterString:@")"];
        NSArray *arr = [newName componentsSeparatedByString:@","];
        CGFloat r = [arr[0] floatValue];
        CGFloat g = [arr[1] floatValue];
        CGFloat b = [arr[2] floatValue];
        return MJUIColorMake(r, g, b);
        
    }else if([name containsString:@"#"] || [name containsString:@"0X"]){
        return [UIColor mj_colorWithHexString:name];
    }else{
        if([name isEqualToString:@"app"]){
            return UIColor.mj_appColor;
        }if([name isEqualToString:@"main"]){
            return UIColor.mj_mainColor;
        }if([name isEqualToString:@"lightApp"]){
            return UIColor.mj_lightAppColor;
        }if([name isEqualToString:@"white"]){
            return UIColor.mj_whiteColor;
        }if([name isEqualToString:@"red"]){
            return UIColor.mj_redColor;
        }if([name isEqualToString:@"black"]){
            return UIColor.mj_blackColor;
        }if([name isEqualToString:@"lightBlack"]){
            return UIColor.mj_lightBlackColor;
        }if([name isEqualToString:@"orange"]){
            return UIColor.mj_orangeColor;
        }if([name isEqualToString:@"orange1"]){
            return UIColor.mj_orangeColor1;
        }if([name isEqualToString:@"gray"]){
            return UIColor.mj_grayColor;
        }if([name isEqualToString:@"lightGray"]){
            return UIColor.mj_lightGrayColor;
        }if([name isEqualToString:@"clear"]){
            return UIColor.clearColor;
        }if([name isEqualToString:@"bg"]){
            return UIColor.mj_backgroundColor;
        }if([name isEqualToString:@"bg1"]){
            return UIColor.mj_backgroundColor1;
        }if([name isEqualToString:@"line"]){
            return UIColor.mj_lineColor;
        }if([name isEqualToString:@"window"]){
            return UIColor.mj_windowColor;
        }if([name isEqualToString:@"blue"]){
            return UIColor.mj_blueColor;
        }
        return [UIColor mj_blackColor];
    }
    
   return [UIColor mj_blackColor];
}

+ (UIColor *)dm_colorWithColorLight:(UIColor *)light dark:(UIColor *)dark {
#if __IPHONE_13_0
    if (@available(iOS 13.0, *)) {
        return [self colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
            switch (traitCollection.userInterfaceStyle) {
                case UIUserInterfaceStyleDark:
                    return dark;
                case UIUserInterfaceStyleLight:
                case UIUserInterfaceStyleUnspecified:
                default:
                    return light;
            }
        }];
    } else {
#endif
//        switch (DMManager.shared.interfaceStyleForLowerSystem) {
//            case DMUserInterfaceStyleDark:
//                return dark;
//            case DMUserInterfaceStyleLight:
//            case DMUserInterfaceStyleUnspecified:
//            default:
//                return light;
//        }
        return light;
#if __IPHONE_13_0
    }
#endif
}

@end


